<template>
  <x-app-course-list :loading.sync="isLoading" :refreshLoading.sync="refreshLoading" :finished="finished" :list="list" @load="getList">
  </x-app-course-list>
</template>

<script>
export default {
  name: 'list',
  props: ['studyFlag'],
  data() {
    return {
      active: 0,
      searchForm: {
        queryType: 1,
        currentPage: 1,
        pageSize: 9,
      },
      isLoading: false,
      refreshLoading: false,
      finished: false,
      list: [],
      total: 0,
    };
  },
  methods: {
    async getList (page) {
      this.isLoading = true
      if (page === 1) {
        this.finished = false;
        this.searchForm.currentPage = 1;
        this.list = []
      };
      this.searchForm.userId = sessionStorage.userId;
      this.searchForm.studyFlag = this.studyFlag;
      const { data, total } = await this.Request.getCourseInfoPage({ params: this.searchForm })
      this.list.push(...data);
      this.total = total;
      if(this.list.length >= total) this.finished = true;
      this.searchForm.currentPage++;
      this.isLoading = false;
      this.refreshLoading = false;
    },
  },
  mounted() {
  }
};
</script>

<style lang="scss" scoped>
</style>
